package com.innazis.jfrogsurvey;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.innazis.jfrogsurvey.config.CommonUtilities;
import com.innazis.jfrogsurvey.config.Constants;
import com.innazis.jfrogsurvey.utility.DialogUtil;

import org.w3c.dom.Text;

/**
 * Created by Inna on 12.07.14.
 */
public class SplashActivity  extends BaseActivity {

    private Button btnSubminUser;
    private TextView tv_user_name;
    private EditText et_user_name;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        if (!CommonUtilities.getInstance(self).isRegisteredSharedPref(self)) {
            btnSubminUser = (Button)findViewById(R.id.btn_submit_user);
            btnSubminUser.setOnClickListener(
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            if (et_user_name.getText().toString().trim().length() != 0){
                            CommonUtilities.getInstance(self)
                                    .putStringValue(Constants.USER,
                                            et_user_name.getText().toString().trim());
                            gotoActivity(self, MainActivity.class);
                            finish();
                            } else {
                                DialogUtil.alert(self, R.string.empty_username);
                            }
                        }
                    }
            );
            tv_user_name = (TextView)findViewById(R.id.tv_user_name);
            et_user_name = (EditText)findViewById(R.id.user_name);
            btnSubminUser.setVisibility(View.VISIBLE);
            tv_user_name.setVisibility(View.VISIBLE);
            et_user_name.setVisibility(View.VISIBLE);
        } else {
            gotoActivity(self, MainActivity.class);
            finish();
        }
    }

}


